<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>

<!--logo部分-->
<div class="container">
    <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-6">
            <img src="${pageContext.request.contextPath }/imgs/book.png"/>欢迎您来到Alone在线购书商城
        </div>
        <div class="col-lg-5 col-md-4 hidden-xs col-sm-6">
                <img src="../../imgs/header.png" />
        </div>
        <div class="col-lg-3 col-md-4 col-sm-12" style="padding-top: 15px;">
            <c:choose>
                <c:when test="${empty sessionScope.user}">
                    <a  onclick="reg();"
                       href="#">注册<span class="sr-only">(current)</span></a>
                    <a  onclick="login();"
                        href="#">登陆<span class="sr-only">(current)</span></a>
                    <a  onclick="login_admin();"
                        href="#">管理员<span class="sr-only">(current)</span></a>

                </c:when>
                <c:otherwise>
                    欢迎您：
                    <a  onclick="user_click();" href="#">${user.name}</a>
                    |
                    <a  onclick="order_click();"  href="#">订单管理</a>
                    |
                    <a  onclick="buy_click();" href="#">查看购物车</a>
                    |
                    <a  data-toggle="modal" data-target="#myModal"

                       href="#">退出账户</a>
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">退出账户</h4>
            </div>
            <div class="modal-body">点击确认就可以退出当前账户</div>
            <div class="modal-footer">
                <button id="tc" type="button" class="btn btn-primary">确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">放弃</button>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--通用模态对话框-->
<div class="modal fade" id="modalDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel2">登陆页面</h4>
            </div>
            <div class="modal-body" style="overflow:scroll;">
                <iframe  id="_allTop" scrolling="auto" name="_allTop" width="100%" height="600px;"
                         frameborder="0">
                </iframe>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

<script type="text/javascript">
    //退出
    $(function () {
        $('#tc').click(function () {
            alert('退出成功!');
            window.location.href = '${pageContext.request.contextPath}/user?action=exit';
        })
    });

</script>

<script type="text/javascript">
    //用户管理
   function user_click(){
        $("#_allTop").attr("src", "${pageContext.request.contextPath}/user?action=info");
        $('#modalDialog').modal({show: true});
        document.getElementById('myModalLabel2').innerText = '用户管理';
    }
    //订单管理
    function order_click(){
        $("#_allTop").attr("src", "${pageContext.request.contextPath }/order?action=queryOrders");
        $('#modalDialog').modal({show: true});
        document.getElementById('myModalLabel2').innerText = '订单管理';
    }

    function buy_click(){
        $("#_allTop").attr("src", "${pageContext.request.contextPath }/jsp/front/buy/car.jsp");
        $('#modalDialog').modal({show: true});
        document.getElementById('myModalLabel2').innerText = '购物车管理';
    }

</script>

<script type="text/javascript">
    function reg() {
        $("#_content2").attr("src", "${pageContext.request.contextPath }/jsp/front/user/reg.jsp");
        $('#model_window2').modal({show: true});
    }
    function login() {
        $("#_content").attr("src", "${pageContext.request.contextPath }/jsp/front/user/login.jsp");
        $('#model_window').modal({show: true});
    }
    function login_admin() {
        $("#_content").attr("src", "${pageContext.request.contextPath }/jsp/admin/login.jsp");
        $('#model_window').modal({show: true});
    }
</script>